package com.socool.sinofaith.view;

import com.socool.sinofaith.R;

import android.app.Dialog;
import android.content.Context;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;

public class ChooseDialog extends Dialog implements
		android.view.View.OnClickListener {
	private TextView tv_left;
	private TextView tv_right;
	private TextView tv_text;
	private OnDialogClickListener onDialogClickListener;

	public ChooseDialog(Context context) {
		super(context, R.style.progress_dialog);
		setContentView(R.layout.dialog_choose);

		tv_left = (TextView) findViewById(R.id.tv_left_choose_dialog);
		tv_right = (TextView) findViewById(R.id.tv_right_choose_dialog);
		tv_text = (TextView) findViewById(R.id.tv_text_choose_dialog);
		tv_left.setOnClickListener(this);
		tv_right.setOnClickListener(this);
		initDialog();
	}

	private void initDialog() {
		setCanceledOnTouchOutside(false);
		WindowManager manager = this.getWindow().getWindowManager();
		Display display = manager.getDefaultDisplay();
		WindowManager.LayoutParams lp = this.getWindow().getAttributes();
		lp.width = (int) (display.getWidth() / 3 * 2);
		this.getWindow().setAttributes(lp);
	}

	public void setText(int index){
		tv_text.setText("已拍第 "+index+" 张,拍完第 4 张 将直接返回 .");
		this.show();
	}
	
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.tv_left_choose_dialog:
			if (onDialogClickListener != null) {
				onDialogClickListener.onLeftClick();
			}
			break;
		case R.id.tv_right_choose_dialog:
			if(onDialogClickListener!=null){
				onDialogClickListener.onRightClick();
			}
			break;

		default:
			break;
		}

	}

	public void setOnDialogClickListener(
			OnDialogClickListener onDialogClickListener) {
		this.onDialogClickListener = onDialogClickListener;
	}

	public interface OnDialogClickListener {
		void onLeftClick();

		void onRightClick();
	}

}
